﻿Public Class m_materiales
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        seguridad.verificapermisos()
    End Sub

    Protected Sub ImageButton4_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton4.Click
        ASPxGridViewExporter1.WritePdfToResponse()
    End Sub

    Protected Sub ImageButton5_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton5.Click
        ASPxGridViewExporter1.WriteXlsToResponse()
    End Sub

    Protected Sub ASPxButton1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ASPxButton1.Click
        Dim query As String = String.Format("INSERT INTO materiales (descripcion) values ('{0}')", txtdesc.Text)
        Try
            Dim conn As New Devart.Data.PostgreSql.PgSqlConnection(seguridad.conexion)
            conn.Open()
            Dim ejec As New Devart.Data.PostgreSql.PgSqlCommand(query, conn)
            ejec.ExecuteNonQuery()
            ASPxGridView1.DataBind()
            conn.Close()
        Catch ex As Exception
            MsgBox("No se pudo insertar el registro en la base de datos")
        End Try



       
        txtdesc.Text = ""
        ASPxGridView1.DataBind()

    End Sub

    Protected Sub ImageButton6_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton6.Click
        Dim sUrl As String = "frmmateriales.aspx"
        Dim sScript As String = "<script language =javascript> "
        sScript += "window.open('" & sUrl & "',null,'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=500,height=300,left=100,top=100');"
        sScript += "</script> "
        Response.Write(sScript)
        Dim repot As New rptMateriales
        repot.MaterialesTableAdapter.Fill(repot.DataSet11.materiales)

    End Sub
End Class